Code
!pip install torch==2.5.0##홈페이지로 돌아가기 RoseTTAFold All-Atom : Krishna et al., Science 384, 291 (2024)
목표: 이 워크숍을 마치면 다음을 수행할 수 있습니다:
작업 내용을 저장하려면 이 노트북의 사본을 개인 Google 드라이브에 저장하세요.
목차
#@markdown Please run as you read the introduction
## 1) clone `rf_diffusion_all_atom` repo to local environment
!git clone https://github.com/baker-laboratory/rf_diffusion_all_atom.git
# move into repo
%cd rf_diffusion_all_atom
## 2) download container used to run RFAA
'''
author Sergey Lyskov - "Minimal example of running Singularity Containers using
Neurodesk tools inside Colab notebook.
Based on https://colab.research.google.com/drive/1g5cnZxj1llRaHmOs4xSglqsXnFkQYuol
-- big thanks to Neurodesk team for sharing this!"
'''
#set environment variables
import os
#set `LR_PRELOAD` to an empy string to prevent any preloaded libraries from interfering
os.environ["LD_PRELOAD"] = "";
#set `APPTAINER_BINDPATH` to `/content` tp ensure colab's working dir is accessible in container
os.environ["APPTAINER_BINDPATH"] = "/content"
#`LMOD_CMD` points to the system used to manage environment settings
os.environ["LMOD_CMD"] = "/usr/share/lmod/lmod/libexec/lmod"
# download script from NeuroDesk
!curl -J -O https://raw.githubusercontent.com/NeuroDesk/neurocommand/main/googlecolab_setup.sh
# make script executable
!chmod +x googlecolab_setup.sh
# setup NeuroDesk env within colab
!./googlecolab_setup.sh
# set path for variable used by LMOD
os.environ["MODULEPATH"] = ':'.join(map(str, list(map(lambda x: os.path.join(os.path.abspath('/cvmfs/neurodesk.ardc.edu.au/neurodesk-modules/'), x),os.listdir('/cvmfs/neurodesk.ardc.edu.au/neurodesk-modules/')))))
# print Alpine Linux image from DockerHub inside container
!apptainer exec docker://alpine cat /etc/alpine-release
# check version of Alpine Linux inside image
!singularity exec docker://alpine cat /etc/alpine-release
# download singularity conatainer file for RF-AA
!wget http://files.ipd.uw.edu/pub/RF-All-Atom/containers/rf_se3_diffusion.sif
# run os-release in RF-SS container
!singularity exec rf_se3_diffusion.sif cat /etc/os-release
#!singularity run shub://vsoch/hello-world
!singularity run docker://godlovedc/lolcow
## 3) download model weights
!wget http://files.ipd.uw.edu/pub/RF-All-Atom/weights/RFDiffusionAA_paper_weights.pt
## 4) initialize git submodules
!git submodule init
!git submodule update
이 워크숍에서는 RFAA 및 RFdiffusionAA의 원리를 살펴보고, 방법론과 응용 프로그램을 검토하여 계산 도구가 생체 분자 과학을 어떻게 재편하고 있는지에 대한 포괄적인 이해를 제공합니다.
지난 몇 번의 워크숍에서 우리는 단백질 전용 시스템에 집중했습니다. 실제로 단백질은 다른 단백질과 복합체를 형성할 뿐만 아니라 다양한 세포 과정 중에 DNA, RNA, 작은 분자 및 기타 비단백질 리간드와 상호 작용합니다.
RoseTTAFold All-Atom (RFAA)의 목표는 이러한 다양한 생체 분자 어셈블리의 일반화된 예측 및 설계를 가능하게 하는 모델을 개발하는 것이었습니다. 단백질에만 집중하는 이전 접근 방식과 달리 RFAA는 작은 분자 및 화학적 변형에 대한 원자 수준 그래프 표현을 단백질 및 핵산에 대한 서열 기반 설명과 통합합니다. 이러한 혁신을 통해 단백질-작은 분자 복합체, 공유 결합된 변형 단백질 및 여러 생체 분자 구성 요소를 포함하는 어셈블리의 정확한 모델링이 가능합니다.
RFAA는 세 가지 트랙 아키텍처와 각 유형의 분자에 맞춘 특수 입력 표현을 통합하여 RoseTTAFold2 (RF2) 프레임워크를 향상시킵니다.
입력 표현: * 단백질 및 핵산: RF2와 유사하게 잔기 또는 염기의 선형 서열로 표현됩니다. * 작은 분자: 노드가 원자에 해당하고 엣지가 결합을 나타내는 원자 그래프로 표현됩니다. 결합 유형(단일, 이중, 삼중, 방향족) 및 입체 화학 정보(키랄성)가 명시적으로 인코딩됩니다. * 공유 변형: 작은 분자 원자를 단백질 잔기에 연결하는 결합이 있는 잔기 그래프의 일부로 표현됩니다.
멀티트랙 네트워크에는 위에 설명된 입력의 별도 표현을 인코딩하는 1D, 2D 및 3D 트랙이 포함되어 있습니다.
위에서 설명한 세 개의 트랙에 대한 초기 입력 후, 시스템은 핵산 염기, 아미노산 잔기 및 자유롭게 움직이는 원자의 연결되지 않은 가스로 표현됩니다. 아키텍처의 다양한 블록을 통해 이 연결되지 않은 가스는 그럴듯한 어셈블리 구조로 변모합니다.
RFAA는 복잡한 생체 분자 어셈블리를 예측하기 위한 강력한 프레임워크를 제공하는 반면, RFdiffusion All-Atom (RFdiffusionAA)은 이러한 기능을 확장하여 작은 분자를 결합하는 단백질을 설계합니다. 확산 기반 작업을 위해 RFAA를 미세 조정함으로써 RFdiffusionAA는 특정 리간드에 맞춤화된 결합 포켓을 가진 드노보 단백질 구조를 생성합니다.
RFdiffusionAA는 무작위 잔기 분포로 시작하여 디노이징 확산 확률 모델(DDPM)을 사용하여 노이즈 구조를 물리적으로 합당한 단백질 골격으로 반복적으로 정제합니다.
RFdiffusionAA의 주요 혁신은 다음과 같습니다: * 무조건 설계 (Unconditional Design): 기존 스캐폴드를 수정하는 대신 처음부터 단백질을 생성할 수 있어 설계의 유연성이 향상됩니다. * 구조적 다양성: 동일한 표적 분자에 대해 다양한 설계를 생성하여 기능적 후보를 찾을 가능성을 높입니다. * 높은 호환성: RFdiffusionAA로 생성된 설계는 AlphaFold2의 예측과 잘 일치하여 계산 모델과 실험 모델 간의 강력한 일치를 나타냅니다.
다음 PDB (7v11)에서 항응고제 OQO(청록색)는 혈액 응고 효소 Factor XIa(녹색)와 상호 작용합니다. OQO는 Factor XIa를 억제하고 출혈 위험을 최소화하면서 혈전증(혈액 응고 형성)을 줄입니다.
Factor XAi를 제거하고 OQO에 결합할 새로운 단백질을 설계해 봅시다. PDB 7v11에서 리간드 OQO에 대한 바인더를 생성하려면 다음을 실행합니다:
예시 (리간드 바인더):
인수 설명 * inference.deterministic=True는 결과가 재현 가능하도록 사용된 난수 생성기를 시드합니다. 즉, inference.design_startnum=X로 실행하면 동일한 결과가 생성됩니다. torch는 CPU/GPU 아키텍처 간의 재현성을 보장하지 않습니다: https://pytorch.org/docs/stable/notes/randomness.html * inference.num_designs=1은 1개의 설계가 생성되도록 지정합니다. * contigmap.contigs=[\'150-150\']은 생성된 단백질의 길이가 150이어야 함을 지정합니다. * diffuser.T=100은 취해진 디노이징 단계 수를 지정합니다.
예상 출력: * output/ligand_only/sample_0.pdb 설계 PDB * output/ligand_only/sample_0_Xt-1_traj.pdb 부분적으로 디노이징된 중간 구조 * output/ligand_only/sample_0_X0-1_traj.pdb 각 단계에서 네트워크가 만든 실제 정보(ground truth)의 예측
INFO: underlay of /usr/bin/nvidia-smi required more than 50 (496) bind mounts
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
DGL backend not selected or invalid. Assuming PyTorch for now.
Setting the default backend to "pytorch". You can change it in the ~/.dgl/config.json file or export the DGLBACKEND environment variable. Valid options are: pytorch, mxnet, tensorflow (all lowercase)
[14:48:53] /opt/dgl/src/runtime/tensordispatch.cc:43: TensorDispatcher: dlopen failed: /opt/conda/envs/env/lib/python3.9/site-packages/dgl/tensoradapter/pytorch/libtensoradapter_pytorch_1.13.1.so: cannot open shared object file: No such file or directory
Using backend: pytorch
/opt/conda/envs/env/lib/python3.9/site-packages/hydra/_internal/defaults_list.py:251: UserWarning: In 'aa': Defaults list is missing `_self_`. See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/default_composition_order for more information
warnings.warn(msg, UserWarning)
[2024-10-23 14:48:58,471][inference.model_runners][INFO] - Reading checkpoint from RFDiffusionAA_paper_weights.pt
loading RFDiffusionAA_paper_weights.pt
loaded RFDiffusionAA_paper_weights.pt
OVERRIDING: You are changing diffuser.T from the value this model was trained with.
[2024-10-23 14:49:04,423][inference.model_runners][INFO] - Loading checkpoint.
[2024-10-23 14:49:04,728][diffusion][INFO] - No IGSO3 cache found at /content/rf_diffusion_all_atom/cached_schedules/T_100_omega_1000_min_sigma_0_02_min_b_1_5_max_b_2_5_schedule_linear.pkl.
[2024-10-23 14:49:04,729][diffusion][INFO] - Calculating IGSO3.
[2024-10-23 14:51:26,713][__main__][INFO] - Making design output/ligand_only/sample_0
[2024-10-23 14:51:26,714][__main__][INFO] - making design 0 of 0:1
[2024-10-23 14:51:26,714][inference.model_runners][INFO] - Using contig: ['150-150']
==============================
*** Open Babel Error in openLib
/usr/lib/openbabel/3.1.0/png2format.so did not load properly.
Error: libXrender.so.1: cannot open shared object file: No such file or directory
With this beta schedule (linear schedule, beta_0 = 0.02, beta_T = 0.14), alpha_bar_T = 0.00022250170877669007
Calculating chi_beta_T dictionary...
Done calculating chi_beta_T dictionaries. They are now cached.
Done calculating chi_beta_T, chi_alphas_T, and chi_abars_T dictionaries.
[2024-10-23 14:53:57,019][inference.model_runners][INFO] - 14:53:57: Timestep 100, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 14:55:40,755][inference.model_runners][INFO] - 14:55:40: Timestep 99, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 14:57:26,554][inference.model_runners][INFO] - 14:57:26: Timestep 98, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 14:59:08,414][inference.model_runners][INFO] - 14:59:08: Timestep 97, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:00:54,301][inference.model_runners][INFO] - 15:00:54: Timestep 96, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:02:35,334][inference.model_runners][INFO] - 15:02:35: Timestep 95, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:04:12,369][inference.model_runners][INFO] - 15:04:12: Timestep 94, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:05:48,541][inference.model_runners][INFO] - 15:05:48: Timestep 93, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:07:32,936][inference.model_runners][INFO] - 15:07:32: Timestep 92, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:09:16,928][inference.model_runners][INFO] - 15:09:16: Timestep 91, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[2024-10-23 15:11:03,153][inference.model_runners][INFO] - 15:11:03: Timestep 90, current sequence: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#@markdown **<font color='#e59454'>Question Time! Run to Show Question**
import ipywidgets as widgets
from IPython.display import display
# Create a Label widget for displaying the full question
question_label = widgets.Label(
value='Q1: RFAA extends RoseTTAFold2 by adding a _______ architecture that processes proteins, nucleic acids, small molecules, and covalent modifications.'
)
# Create fill-in-the-blank input field with wider text box
question_1_input = widgets.Text(
placeholder='Enter your answer here',
layout=widgets.Layout(width='600px') # Adjust the width here
)
# Create submit button for fill-in-the-blank
submit_button_1 = widgets.Button(description="Submit Answer")
# Define what happens when the button is clicked
def on_button_clicked_1(b):
if question_1_input.value.lower() == 'three-track':
print("Correct!")
else:
print("Try again!")
submit_button_1.on_click(on_button_clicked_1)
# Display the question label, input field, and submit button
display(question_label, question_1_input, submit_button_1)#@markdown **<font color='#e59454'>Question Time! Run to Show Question**
import ipywidgets as widgets
from IPython.display import display
# Create a Label widget to display the full question
question_label = widgets.Label(
value="Q2: How does RFdiffusionAA generate binding pockets for small molecules?"
)
# Create a multiple-choice question
question_2 = widgets.RadioButtons(
options=['A) By modifying pre-existing protein structures.',
'B) By using random selection of protein scaffolds.',
'C) By iteratively refining random residue distributions around target small molecules.',
'D) By relying on classical docking methods.'],
disabled=False,
layout=widgets.Layout(width='90%') # Adjusting width for better display
)
# Create a submit button
submit_button = widgets.Button(description="Submit Answer", layout=widgets.Layout(width='30%'))
# Define what happens when the button is clicked
def on_button_clicked(b):
if question_2.value == 'C) By iteratively refining random residue distributions around target small molecules.':
print("Correct!")
else:
print("Try again!")
submit_button.on_click(on_button_clicked)
# Group the question, answer options, and button in a VBox layout
quiz_layout = widgets.VBox([question_label, question_2, submit_button])
# Display the question, options, and button
display(quiz_layout)#@markdown **<font color='#e59454'>Question Time! Run to Show Question**
import ipywidgets as widgets
from IPython.display import display
# Create a Label widget for displaying the full question
question_label = widgets.Label(
value='Q3: One of the key advantages of RFdiffusionAA is that it generates proteins from _______ rather than modifying existing scaffolds.'
)
# Create fill-in-the-blank input field with wider text box
question_3_input = widgets.Text(
placeholder='Enter your answer here',
layout=widgets.Layout(width='600px') # Adjust the width here
)
# Create submit button for fill-in-the-blank
submit_button_3 = widgets.Button(description="Submit Answer")
# Define what happens when the button is clicked
def on_button_clicked_3(b):
if question_3_input.value.lower() == 'scratch':
print("Correct!")
else:
print("Try again!")
submit_button_3.on_click(on_button_clicked_3)
# Display the question label, input field, and submit button
display(question_label, question_3_input, submit_button_3)#@markdown **<font color='#e59454'>Question Time! Run to Show Question**
import ipywidgets as widgets
from IPython.display import display
# Create a Label widget to display the full question
question_label = widgets.Label(
value="Q4: What do the encodings represent for the 2D track in RFAA?"
)
# Create a multiple-choice question
question_2 = widgets.RadioButtons(
options=['A) A 3D voxel grid representing the 3D spatial arrangement of atoms in the molecule.',
'B) A sequence of residues encoded using one-hot encoding for amino acids.',
'C) The pairwise relationship between inputs such as chemical bonds and distances between atoms.',
'D) A graph representation that captures molecular interactions in a graph neural network framework.'],
disabled=False,
layout=widgets.Layout(width='90%') # Adjusting width for better display
)
# Create a submit button
submit_button = widgets.Button(description="Submit Answer", layout=widgets.Layout(width='30%'))
# Define what happens when the button is clicked
def on_button_clicked(b):
if question_2.value == 'C) The pairwise relationship between inputs such as chemical bonds and distances between atoms.':
print("Correct!")
else:
print("Try again!")
submit_button.on_click(on_button_clicked)
# Group the question, answer options, and button in a VBox layout
quiz_layout = widgets.VBox([question_label, question_2, submit_button])
# Display the question, options, and button
display(quiz_layout)